package com.leetcode;

import java.util.Arrays;

/**
 * 1672. 最富有客户的资产总量
 *
 * @author fy
 * @date 2022/4/14 17:06
 */
public class Solution1672 {

    public int maximumWealth1(int[][] accounts) {
        if (accounts == null || accounts.length == 0 || accounts[0].length == 0) {
            return 0;
        }
        int max = 0;
        for (int[] account : accounts) {
            int nums = 0;
            for (int num : account) {
                nums += num;
            }
            max = Math.max(max, nums);
        }
        return max;
    }

    /**
     * java8简化版本
     *
     * @param accounts
     * @return
     */
    public int maximumWealth(int[][] accounts) {
        int maxWealth = 0;
        for (int[] account : accounts) {
            maxWealth = Math.max(maxWealth, Arrays.stream(account).sum());
        }
        return maxWealth;
    }

}
